/**
 * Created by androidlongs on 17/3/30.
 */

//提交功能
function commitAddSubFunction(){
    console.log("添加试题 .. ")

    var subTitle = $('#ta_Sub_title').val();
    var subSgine = $('#ta_Sub_Sign').val();
    //去掉前后所有的空格
    subTitle = subTitle.replace(/(^\s*)|(\s*$)/g, "");
    subSgine = subSgine.replace(/(^\s*)|(\s*$)/g, "");
    console.log(subSgine+ " - - - "+subTitle)

    if (subTitle == null || subTitle.length < 0) {
        alert("请输入试题标题")
        return;
    }

    if (subSgine == null || subSgine.length < 0) {
        alert("请输入题记")
        return;
    }

    var url = addSubUrl();
    console.log("url "+url);
    //提交数据
    $.post(
        url,
        {
            "subTitle": encodeURI(subTitle),
            "subSgine": encodeURI(subSgine)
        },
        function (data, textStatus) {
            if (textStatus == "success") {
                console.log("请求响应成功 ")
                var code = data.code;
                var message = data.message;
                if(code==1000){
                    alert("添加成功");
                }else{
                    alert("添加失败.."+message);
                }
            } else {
                console.log("请求响应失败 ")

            }
            //decodeURI(data)
            var result = "getJson 响应数据为 " + data+ " 请求结果为  " + textStatus;

            console.log(result)
            console.log(data.code+"  "+data.message);
        }, "json");


}